<?php
class Work_day_model extends CI_Model{

	function getWorkDay($num, $offset) {
		$query = $this->db->get('emp_workday', $num, $offset);
		return $query;
	}

	function getAllWorkDay(){
		$data=$this->db->query('select * from emp_workday');
		return $data;
	}

	function delWorkDayById($id){
		$query=$this->db->query("select employeid from emp_workday where id=$id");
		$row = $query->row_array();
		$employeid = $row['employeid'];

		$this->db->where('id',$id);
		$this->db->delete('emp_workday');

		return $employeid;
	}

	function getWorkDayByEmployeId($employeid){
		$this->db->where('employeid',$employeid);
		$data=$this->db->get('emp_workday');
		return $data;
	}

	function addWorkDay(){
		$data=array(
		//				'id'=>$_POST['id'],
						'employeid'=>$_POST['employeid'],
						'workday'=>$_POST['workday'],
						'shour'=>$_POST['shour'],
						'sminute'=>$_POST['sminute'],
						'ehour'=>$_POST['ehour'],
						'eminute'=>$_POST['eminute']
		);
		$this->db->insert('emp_workday',$data);
		return $this->db->insert_id();
	}

	function updateWorkDay($id,$data){
		$this->db->where('id',$id);
		$this->db->update('emp_workday',$data);
	}
}
?>